package com.lb.jwitter.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.ContextConfiguration;

import com.lb.jwitter.service.ConditionReport;
import com.lb.jwitter.service.TblCTDTDMNgayTrongTuan;
import com.lb.jwitter.service.TblCTDTDMNgayTrongTuanService;
import com.lb.jwitter.service.TblCTDTDMTietHocService;
import com.lb.jwitter.service.TblDKMHDotDK;
import com.lb.jwitter.service.TblDKMHKetqua;
import com.lb.jwitter.service.TblDKMHTaiKhoanHocVien;

import com.lb.jwitter.util.ApplicationContextProvider;
import com.lb.jwitter.util.KetQuaDangKy;
import com.lb.jwitter.util.QuyenDangKy;
import com.lb.jwitter.util.ThoiKhoaBieuDuKien;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;

@ContextConfiguration(locations="classpath:beans.xml") 
public class GetKetQuaDangKyAction {

	private TblDKMHTaiKhoanHocVien tblDKMHTaiKhoanHocVien;
	public TblDKMHTaiKhoanHocVien getTblDKMHTaiKhoanHocVien() {
		return tblDKMHTaiKhoanHocVien;
	}

	public void setTblDKMHTaiKhoanHocVien(
			TblDKMHTaiKhoanHocVien tblDKMHTaiKhoanHocVien) {
		this.tblDKMHTaiKhoanHocVien = tblDKMHTaiKhoanHocVien;
	}

	private int soTietTrongNgay;

	public int getSoTietTrongNgay() {
		return soTietTrongNgay;
	}

	private List<TblDKMHKetqua> tblDKMHKetquas;
	
	public List<TblDKMHKetqua> getTblDKMHKetquas() {
		return tblDKMHKetquas;
	}

	public void setTblDKMHKetquas(List<TblDKMHKetqua> tblDKMHKetquas) {
		this.tblDKMHKetquas = tblDKMHKetquas;
	}
	
	private List<KetQuaDangKy> ketQuaDangKys;
	public List<KetQuaDangKy> getKetQuaDangKys() {
		return ketQuaDangKys;
	}

	public void setKetQuaDangKys(List<KetQuaDangKy> ketQuaDangKys) {
		this.ketQuaDangKys = ketQuaDangKys;
	}

	private Boolean trongHanDK;
	public Boolean getTrongHanDK() {
		return trongHanDK;
	}

	public void setTrongHanDK(Boolean trongHanDK) {
		this.trongHanDK = trongHanDK;
	}

	private TblCTDTDMTietHocService tblCTDTDMTietHocService;


	private List<TblCTDTDMNgayTrongTuan> ngayTrongTuans;
	public List<TblCTDTDMNgayTrongTuan> getNgayTrongTuans() {
		return ngayTrongTuans;
	}

	public void setNgayTrongTuans(List<TblCTDTDMNgayTrongTuan> ngayTrongTuans) {
		this.ngayTrongTuans = ngayTrongTuans;
	}
	
	private QuyenDangKy quyenDK;



	public QuyenDangKy getQuyenDK() {
		return quyenDK;
	}

	public void setQuyenDK(QuyenDangKy quyenDK) {
		this.quyenDK = quyenDK;
	}

	@Autowired // Injected by Spring 
	ApplicationContextProvider contextProvider; 
	 	 
	public String execute() throws Exception
	{

		Map session = ActionContext.getContext().getSession();
		tblDKMHTaiKhoanHocVien =  (TblDKMHTaiKhoanHocVien) session.get("taiKhoanHocVien");
	     if( tblDKMHTaiKhoanHocVien == null) return "noprivilege";
	     
	     Integer dotDKId = (Integer) session.get("dotDKId");
	     
	    ApplicationContext context = contextProvider.getApplicationContext(); 
	    

	    tblCTDTDMTietHocService = (TblCTDTDMTietHocService) context.getBean("tbl_CTDT_DM_TietHocClient");
	    
	    	ketQuaDangKys = (List<KetQuaDangKy>) session.get("ketQuaDangKys");
	    	
	    	List<ConditionReport> cons = new ArrayList<ConditionReport>();
	    	{ 
		        ConditionReport con = new ConditionReport(); 
		        con.setCol("ma");
		        con.setValue1("0");
		        con.setOperator("ne");
		        cons.add(con);	
		   }
		    soTietTrongNgay = tblCTDTDMTietHocService.counttblCTDTDMTietHocByCondition(cons);

		    trongHanDK = (Boolean) session.get("trongHanDK");

		    quyenDK = (QuyenDangKy) session.get("quyenDK");

		return Action.SUCCESS;

	}


	
	
	
	
	
}
